;
var member_reg_ops = {
    init: function () {
        this.eventBind();
    },
    eventBind: function () {
        $(".reg_warp .do_reg").click(function () {
            /*按钮重复点击控制*/
            var btn_target = $(this);
            if (btn_target.hasClass("disabled")) {
                alert("正在处理请不要重复点击");
                return;
            }
            // alert("1111")
            var nick_name = $(".reg_warp input[name=nick_name]").val();
            var login_name = $(".reg_warp input[name=login_name]").val();
            var password_1 = $(".reg_warp input[name=login_pwd1]").val();
            var password_2 = $(".reg_warp input[name=login_pwd2]").val();

            if (login_name == undefined || login_name.length < 1) {
                common_ops.alert("用户名错误");
                return;
            }

            if (password_1 == undefined || password_1.length < 5) {
                common_ops.alert("请确认密码是否正确，密码长度不小于5");
                return;
            }

            if (password_2 == undefined || password_2 != password_1) {
                common_ops.alert("确认密码与密码不一致");
                return;
            }
            btn_target.addClass("disabled");
            $.ajax({
                url: common_ops.buildUrl("/member/reg"),
                type: "POST",
                data: {
                    nick_name: nick_name,
                    login_name: login_name,
                    login_pwd1: password_1,
                    login_pwd2: password_2
                },
                dataType: "json",
                success: function (res) {
                    btn_target.removeClass("disabled");
                    var callback = null;
                    if (res.code == 200) {
                        callback = function () {
                            window.location.href = common_ops.buildUrl("/");
                        }

                    }
                    common_ops.alert(res.msg, callback);
                }
            })

        });
    }
};

$(document).ready(function () {
    member_reg_ops.init();
})